package com.login.learn.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.login.learn.dao.UserDo;
import com.login.learn.dto.UserDto;
import org.apache.tomcat.jni.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Controller
@RequestMapping("")
public class Login2Controller {

    @Autowired
    RedisTemplate redisTemplate;

    @RequestMapping("/login")
    public String login(UserDto userDto) throws InterruptedException {
        return "login";
    }

    @RequestMapping("/test")
    public String test(HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
        UserDo userDo = new UserDo();
        userDo.setId(24232L);
        StpUtil.login(userDo.getId());
        StpUtil.getLoginIdAsString();
        return "success";
    }

    @RequestMapping("/qq")
    public String qq(HttpServletRequest request, HttpServletResponse response) throws InterruptedException {
        UserDo userDo = new UserDo();
        userDo.setId(24232L);
        StpUtil.login(userDo.getId());
        StpUtil.getLoginIdAsString();
        return "qq";
    }
}
